﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using park.Common;

namespace park.Equipment
{
    public partial class InspectionTerminalList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string method = Request.Params["method"];
                if (!string.IsNullOrEmpty(method))
                {
                    switch (method)
                    {
                        case "ListInspectionTerminal":
                            {
                                PrintResult();
                                break;
                            }
                        case "DeleteInspectionTerminal":
                            {
                                DeleteInspectionTerminal();
                                break;
                            }
                    }

                }
            }
        }
        private void DeleteInspectionTerminal()
        {
            string id =Request.Params["id"];

            cn.linkit.epark.ServiceList sl = new cn.linkit.epark.ServiceList();
            bool flag = sl.DeleteInspectionTerminal(id);
           // bool flag = false;

            Response.Write("{" + string.Format("\"isSuccess\":\"{0}\"", flag.ToString().ToLower()) + "}");
            Response.End();
        }
        private void PrintResult()
        {

            string code = Request.Params["code"];
            string model = Request.Params["model"];
            DateTime beginDate = string.IsNullOrEmpty(Request.Params["beginDate"])?DateTime.Parse("1900-01-01"):DateTime.Parse(Request.Params["beginDate"]);
            DateTime endDate =string.IsNullOrEmpty(Request.Params["endDate"])?DateTime.Parse("1900-01-01"):DateTime.Parse(Request.Params["endDate"]);

            int page = int.Parse(Request.Params["page"]);
            int size = int.Parse(Request.Params["size"]);

            cn.linkit.epark.ServiceList sl = new cn.linkit.epark.ServiceList();
 
            string result = sl.ListInspectionTerminal(code,model,beginDate,endDate,page, size);

            //string result = "{"
            //    + "    \"ListInspectionTerminal\":["
            //    + "    {"
            //    + "        \"ID\":\"1\","
            //    + "        \"No\":\"TSN4564\","
            //    + "        \"Model\":\"ZX-T-1893\","
            //    + "        \"Connection\":\"18627870000\","
            //    + "        \"Description\":\"配件说明.......\","
            //    + "        \"Date\":\"2012-12-05 18:00\","
            //    + "        \"EmpCode\":\"SN1565212\""
            //    + "    },"
            //    + "    {"
            //    + "        \"ID\":\"2\","
            //    + "        \"No\":\"TSN4564\","
            //    + "        \"Model\":\"ZX-T-1893\","
            //    + "        \"Connection\":\"18627870000\","
            //    + "        \"Description\":\"配件说明.......\","
            //    + "        \"Date\":\"2012-12-05 18:00\","
            //    + "        \"EmpCode\":\"SN1565212\""
            //    + "    }],"
            //    + "    \"RowsCount\":234"
            //    + "}";



            Response.Write(result);
            Response.End();

        }
    }
}